﻿using System.Runtime.Serialization;
using Microsoft.Commerce.Contracts;

namespace MusicWorks.Service.DataContracts
{
    public abstract class BaseCommerceEntity : ICommerceEntity
    {
        /// <summary>
        /// The entity instance.
        /// </summary>
        protected CommerceEntity _commerceEntity;

        protected BaseCommerceEntity()
        {
        }

        protected BaseCommerceEntity(string modelNameDefinition)
        {
            _commerceEntity = new CommerceEntity(modelNameDefinition);
        }


        protected BaseCommerceEntity(CommerceEntity entity)
        {
            _commerceEntity = entity;
        }


        /// <summary>
        /// Gets or sets the commerce entity.
        /// </summary>
        /// <value>The commerce entity.</value>
        [IgnoreDataMember]
        public CommerceEntity CommerceEntity
        {
            get { return _commerceEntity; }
            set { _commerceEntity = value; }
        }

        #region ICommerceEntity Members

        public string Id
        {
            get { return _commerceEntity.Id; }
            set { _commerceEntity.Id = value; }
        }

        public string ModelName
        {
            get { return _commerceEntity.ModelName; }
            set { _commerceEntity.ModelName = value; }
        }

        [IgnoreDataMember]
        public CommercePropertyCollection Properties
        {
            get { return _commerceEntity.Properties; }
            set { _commerceEntity.Properties = value; }
        }

        public CommerceEntity ToCommerceEntity()
        {
            return _commerceEntity;
        }

        #endregion
    }
}